//
//  MeViewController.m
//  AI
//
//  Created by zjhc on 2018/1/5.
//  Copyright © 2018年 zjhc. All rights reserved.
//  Description:个人中心模块Controller

#import "MeViewController.h"
#import "MeCell.h"
#import "AINavigationViewController.h"
#import "LoginViewController.h"
#import "UserManage.h"

@interface MeViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *tableView;

@end

@implementation MeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.tableView reloadData];
    self.automaticallyAdjustsScrollViewInsets = false;

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];

}

-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 1;
}

-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return  4;
}

-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    MeCell * cell = [tableView dequeueReusableCellWithIdentifier:@"meCell" forIndexPath:indexPath];
    
    switch (indexPath.row) {
        case 0:
            cell.title.text = @"签到";
            break;
        case 1:
            cell.title.text = @"评分";
            break;
        case 2:
            cell.title.text = @"通知";
            break;
        case 3:
            cell.title.text = @"退出账号";
            cell.title.textColor = [UIColor redColor];
            break;
            
        default:
            break;
    }
    
    return  cell;
}

-(CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    return 50.0;
}

- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (indexPath.row == 3) {
        UIStoryboard *loginStoryBoard = [UIStoryboard storyboardWithName:@"Login" bundle:nil];
        
        LoginViewController *login =(LoginViewController *)[loginStoryBoard instantiateViewControllerWithIdentifier:@"LoginViewController"];
        //1.模态显示
       /* AINavigationViewController *nav =(AINavigationViewController *)[loginStoryBoard instantiateViewControllerWithIdentifier:@"UINavigationController"];
        [self presentViewController:nav animated:YES completion:^{
            //        [NSUserDefaultsUtil removeuuid];
        }];*/
//       2. Push出页面 3.Storyboard引用（待测试）这种方式最简单。
        [self.navigationController pushViewController:login animated:YES];
        
        [[UserManage sharedUserManage] cleanAllUseData];
    }
    
}


@end
